import fly from "../main"


/**
 * 获取车辆列表
 * @returns {Promise<{}>}
 */
export async function getCars() {
  let response = {}
  await fly.get(`/v2/car`).then((res) => {
    response = res.data
  })
  return response;
}


/**
 * 添加车辆信息
 * @param $car 车辆数据
 * @returns {Promise<{}>}
 */
export async function addCar($car) {
  let response = {}
  await fly.post(`/v2/car`, $car).then((res) => {
    response = res.data
  })
  return response;
}


/**
 * 删除车辆信息
 * @param $id 车辆id
 * @returns {Promise<{}>}
 */
export async function delCar($id) {
  let response = {}
  await fly.delete(`/v2/car/${$id}`).then((res) => {
    response = res.data
  })
  return response;
}


/**
 * 获取车辆信息
 * @param $id 车辆id
 * @returns {Promise<{}>}
 */
export async function getCar($id) {
  let response = {}
  await fly.get(`/v2/car/${$id}`).then((res) => {
    response = res.data
  })
  return response;
}

/**
 * 更新车辆信息
 * @param id
 * @param car
 * @returns {Promise<{}>}
 */
export async function updateCar(id,car) {
  let response = {}
  await fly.put(`/v2/car/${id}`, car).then((res) => {
    response = res.data
  })
  return response;
}

